<?php

include 'lib/ActionsConnection.php';
include 'lib/MarksRetriever.php';

// If the key is send via POST, use POST instead of GET.
if(isset($_POST['k'])){
    $_GET = $_POST;
}

$user = $_GET['u'];
$pass = $_GET['p'];
$key = $_GET['k'];

if($user == "demo" && $pass == "demo"){
    logger("Marks", "DEMO", $key);
    header ("Location: demodata/marks.xml");
    exit();
}

$actions = new ActionsConnection($user, $pass, $key);

$marks = new MarksRetriever($actions);

$marks->retrieve();
$xml = $marks->toXml();

header ("Content-Type:text/xml");

echo $xml;

$actions->destroy();

?>